#include<stdio.h>
struct NODE
{
	int k;
	struct NODE* next;
};
int main()
{
	struct NODE m[5], * p = m, * q = m + 4;
	int i = 0;
	while (p != q)
	{
		p->k = ++i;
		p++;
		q->k = i++;
		q--;
	}
	q->k = i;   
	for (i = 0; i < 5; i++)
	{
		printf("%d", m[i].k);
	}
	printf("\n");
}
typedef struct {
    int front;
    int back;
    int* a;
    int k;

} MyCircularQueue;


MyCircularQueue* myCircularQueueCreate(int k) {
    MyCircularQueue* obj = (MyCircularQueue*)malloc(sizeof(MyCircularQueue));
    obj->a = (int*)malloc((k + 1) * sizeof(int));
    obj->front = 0;
    obj->back = 0;
    obj->k = k;
}

bool myCircularQueueEnQueue(MyCircularQueue* obj, int value) {
    if (myCircularQueueIsFull(obj))
    {
        return false;
    }
    else
    {
        obj->a[obj->back] = value;
        ++obj->back;
        (obj->back + obj->k) %= obj->k;

    }
}

bool myCircularQueueDeQueue(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj))
    {
        ++obj->front;
    }
    (obj->front + obj->back) %= obj->k;
}

int myCircularQueueFront(MyCircularQueue* obj) {
    if (myCircularQueueIsEmpty(obj))
    {
        return -1;
    }
    else
    {
        return obj->a[obj->front];
    }
}

int myCircularQueueRear(MyCircularQueue* obj) {

}

bool myCircularQueueIsEmpty(MyCircularQueue* obj) {
    return obj->back == obj->front;
}

bool myCircularQueueIsFull(MyCircularQueue* obj) {
    return (obj->back) % (obj->k) == obj->front;
}

void myCircularQueueFree(MyCircularQueue* obj) {
    free(obj->a);
    free(obj);
}

/**
 * Your MyCircularQueue struct will be instantiated and called as such:
 * MyCircularQueue* obj = myCircularQueueCreate(k);
 * bool param_1 = myCircularQueueEnQueue(obj, value);

 * bool param_2 = myCircularQueueDeQueue(obj);

 * int param_3 = myCircularQueueFront(obj);

 * int param_4 = myCircularQueueRear(obj);

 * bool param_5 = myCircularQueueIsEmpty(obj);

 * bool param_6 = myCircularQueueIsFull(obj);

 * myCircularQueueFree(obj);
*/